package com.sky.mapper;

import com.sky.dto.MeetingRoomQueryDTO;
import com.sky.entity.MeetingRoom;
import com.sky.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MeetingRoomMapper {

    /**
     * 查询所有会议室
     * @param o
     * @return
     */
    @Select("select * from meeting_room")
    List<MeetingRoom> selectList(Object o);

    /**
     * 根据id获取会议室信息
     * @param meetingRoomId
     * @return
     */
    @Select("select * from meeting_room where id=#{meetingRoomId}")
    MeetingRoom getById(Long meetingRoomId);

    void update(MeetingRoom meetingRoom);


    @Delete("delete from meeting_room where id=#{id}")
    void delete(Integer id);

    void insert(MeetingRoom meetingRoom);

    /**
     * 根据会议室ID更新会议室状态为锁定
     * @param meetingRoomId 会议室ID
     * @return 更新的行数
     */
    @Update("UPDATE meeting_room SET status = '锁定' WHERE id = #{meetingRoomId}")
    int updateStatusToLocking(Long meetingRoomId);

    /**
     * 除了时间外都筛选一遍会议室
     * @param query
     * @return
     */
    List<MeetingRoom> queryByConditions(MeetingRoomQueryDTO query);
}
